import request from "@/utils/request";

// 获取视频播放凭证
const getUploadAuth = (query) => {
  return request({
    url: "/website/video",
    method: "post",
    data: query,
  });
};

// 获取视频列表
const getVideoList = (query) => {
  return request({
    url: "/website/video/list",
    method: "get",
    params: query,
  });
};

// 获取播放凭证
const getPlayAuth = (id) => {
  return request({
    url: `/website/video/playAuth/${id}`,
    method: "get",
  });
};

// 获取视频详情
const getVideoDetail = (id) => {
  return request({
    url: `/website/video/${id}`,
    method: "get",
  });
};

// 更新视频
const updateVideo = (query) => {
  return request({
    url: `/website/video`,
    method: "put",
    data: query,
  });
};

// 删除视频
const deleteVideo = (id) => {
  return request({
    url: `/website/video/${id}`,
    method: "delete",
  });
};

// 获取分类列表
const getCategoryList = (query) => {
  return request({
    url: `/website/media/category/list`,
    method: "get",
    params: query,
  });
};

// 获取标签列表
const getCategoryTab = (query) => {
  return request({
    url: `/website/tag/list`,
    method: "get",
    params: query,
  });
};

// 刷新上传凭证
const refreshUploadAuth = (vid) => {
  return request({
    url: `/website/video/refresh`,
    method: "post",
    data: {
      vid: vid,
    },
  });
};

export {
  getUploadAuth,
  getVideoList,
  getPlayAuth,
  getVideoDetail,
  updateVideo,
  deleteVideo,
  getCategoryList,
  getCategoryTab,
  refreshUploadAuth,
};
